#include "Csillag.hh"

using namespace Geom;
using namespace Gui;
using namespace Network;

QImage Csillag::img("img/csillag.png");

Csillag::Csillag(QWidget* parent, StateChanged::StarInfo const& si):
    QWidget(parent),
    si(si)
{
    resize(64, 64);
    Vector<> const sizeVec(parent->size().width(), parent->size().height());
    Vector<> const v = server_to_client(si.position, sizeVec);
    move(v.x, v.y);
    id = si.id;
}


void Csillag::paintEvent(QPaintEvent* ev) {
    DONTCARE(ev);
    QPainter painter(this);
    QRect rect;
    rect.setSize(size());
    painter.drawImage(rect, img);
}

void Csillag::mousePressEvent(QMouseEvent* ev) {
    DONTCARE(ev);

    if (ev->buttons() & Qt::LeftButton) {
        emit left_clicked(this);
    }

    if (ev->buttons() & Qt::RightButton) {
        emit right_clicked(this);
    }
}

u8 Csillag::get_id() {
	return id;
}

Network::StateChanged::StarInfo::PlanetList Csillag::get_planets() {
	return si.planets;
}
